﻿Public Class clsWall
    Public Text As String
    Private Sub OpenComposerText(ByRef obj As WebBrowser)
        obj.Navigate("http://m.facebook.com/composer/")
    End Sub

    Private Sub SendComposerText(ByRef obj As WebBrowser)
        If (obj.Document.GetElementsByTagName("textarea").GetElementsByName("status").Count > 0) Then
            obj.Document.GetElementsByTagName("textarea").GetElementsByName("status").Item(0).InnerText = Text
            obj.Document.GetElementById("composer_form").InvokeMember("submit")
        End If
    End Sub

    Public Sub ComposerText(ByRef obj As WebBrowser, ByVal Status As String)
        Text = Status
        OpenComposerText(obj)
    End Sub

    Public Sub ComposerTextFail(ByRef obj As WebBrowser)
        Debug.Print("post status fail")
    End Sub

    Public Sub ComposerTextSuccess(ByRef obj As WebBrowser)
        Debug.Print("post status success")
    End Sub

    Public Sub HandleWall(ByRef obj As WebBrowser)
        If obj.Document IsNot Nothing Then
            If (obj.Document.GetElementById("m_home_notice") IsNot Nothing) And InStr(obj.Document.Body.InnerHtml, """y h z""", CompareMethod.Text) > 0 Then
                ComposerTextSuccess(obj)
            ElseIf (obj.Document.GetElementById("m_home_notice") IsNot Nothing) And InStr(obj.Document.Body.InnerHtml, """y z h ba""", CompareMethod.Text) > 0 Then
                ComposerTextFail(obj)
            Else
                SendComposerText(obj)
            End If
        End If
    End Sub

End Class
